<template>
	<view>
		<topInfo :userInfo="userInfo"></topInfo>
		<PanelList :obejdata="obejdata" @childEvent="handleChildEvent"></PanelList>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	import topInfo from '@/components/index/topInfo.vue'
	import PanelList from '@/components/index/panobj.vue'
	export default {
		components: {
			topInfo,
			PanelList
		},
		data() {
			return {
				obejdata: [],
				typeid: null,
				currentPage: 1,
				pageSize: 9,
				isLoading: false,
			}
		},
		onLoad() {
			this.getPro()
		},
		computed: {
			...mapState(['userInfo']),
		},
		onReachBottom() {
		  if (!this.isLoading) {
		    this.currentPage++;
		    this.getPro(true);
		  }
		},
		methods: {
			handleChildEvent(data) {
				const tabTypeMapping = {
					'全部': null,
					'战略投资区': 1,
					'C轮投资区': 2,
					// Add more tabs and typeid values as needed
				};
				this.typeid = tabTypeMapping[data];

				this.getPro()
			},
			getPro(isLoadMore = false) {
			  const param = {
			    current: this.currentPage,
			    size: this.pageSize,
			    partitionId: this.typeid,
			  };
			
			  this.isLoading = true;
			
			  this.$request.get('/CatProjec/all', param).then((res) => {
			    if (res.code === 200) {
			      const projects = res.data.project.records;
			
			      if (isLoadMore) {
			        // 上拉加载时追加数据
			        this.obejdata = this.obejdata.concat(projects);
			      } else {
			        // 下拉刷新时重置数据
			        this.obejdata = projects;
			      }
			
			      this.isLoading = false;
			    }
			  });
			},

		}
	}
</script>

<style>
	html,
	  body {
	    overflow: hidden;
	  }
	
	  /* 设置滚动容器，允许手动滚动 */
	  .scroll-container {
	    overflow-y: auto;
	    height: 100vh; /* 或者设置固定高度，适应你的需求 */
	  }
</style>